package com.central.scheduler.spi.task.request;

import com.central.common.model.ResourceInfo;
import com.central.common.properties.Property;
import com.central.scheduler.spi.enums.TaskTimeoutStrategy;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * @author Tindy
 * @date 2021/10/26
 * @describe to master/worker task transport
 */
@Getter
@Setter
@ToString
public class TaskRequest {

    /**
     * task id
     */
    private Long taskInstanceId;

    /**
     * task name
     */
    private String taskName;

    /**
     * task first submit time.
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date firstSubmitTime;

    /**
     * task start time
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date startTime;

    /**
     * task type
     */
    private String taskType;

    /**
     * host
     */
    private String host;

    /**
     * task execute path
     */
    private String executePath;

    /**
     * log path
     */
    private String logPath;

    /**
     * processId
     */
    private int processId;

    /**
     * appIds
     */
    private String appIds;

    /**
     * process instance id
     */
    private Long processInstanceId;


    /**
     * process instance schedule time
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date scheduleTime;

    /**
     * task instance local parameters
     */
    private List<Property> localParams;
    /**
     * process instance global parameters
     */
    private List<Property> globalParams;


    /**
     * execute user id
     */
    private long userId;
    private String username;


    /**
     * command type if complement
     */
    private int cmdTypeIfComplement;

    /**
     * task queue
     */
    private String queue;


    /**
     * process define id
     */
    private Long processDefineId;

    /**
     * project id
     */
    private Long proId;
    private String proName;

    /**
     * envFile
     */
    private String envFile;

    /**
     * environmentConfig
     */
    private String environmentConfig;

    /**
     * task AppId
     */
    private String taskAppId;

    /**
     * task timeout strategy
     */
    private TaskTimeoutStrategy taskTimeoutStrategy;

    /**
     * task timeout
     */
    private int taskTimeout;

    /**
     * worker group
     */
    private Long workerGroupId;

    /**
     * delay execution time.
     */
    private int delayTime;

    /**
     * Task Logger name should be like: Task-{processDefinitionId}-{processInstanceId}-{taskInstanceId}
     */
    private String taskLogName;

    private List<ResourceInfo> resources;
    private String taskContent;



    private Map<String, Property> paramsMap;


    /**
     * sql TaskExecutionContext
     */
    private SQLTaskExecutionContext sqlTaskExecutionContext;
    /**
     * datax TaskExecutionContext
     */
    private DataxTaskExecutionContext dataxTaskExecutionContext;

    /**
     * flink sql TaskExecutionContext
     */
    private FlinkSqlTaskExecutionContext flinkSqlTaskExecutionContext;

}
